

#ifndef SpriteBatcher_h
#define SpriteBatcher_h

#include <Defines.h>

// Riccsson includes.
#include <System/Object.h>
#include <System/ArgumentException.h>
#include <System/Array.h>
#include <System/Collections/Generic/Queue.h>

// XNA includes.
#include "GraphicsDevice.h"
#include "SpriteSortMode.h"
#include "SpriteBatchItem.h"
#include "Vertices/PrimitiveType.h"
#include "Vertices/VertexPositionColorTexture.h"

namespace Riccsson
{
	namespace Xna
	{
		namespace Framework
		{
			namespace Graphics
			{
	            /*internal*/ class SpriteBatcher
					: public Riccsson::System::Object
	            {
		            private: const int InitialBatchSize;
		            private: const int InitialVertexArraySize;

	                /*readonly*/ GC_PTR<Riccsson::System::Collections::Generic::List<GC_PTR<SpriteBatchItem>>> _batchItemList;

	                /*readonly*/ GC_PTR<Riccsson::System::Collections::Generic::Queue<GC_PTR<SpriteBatchItem>>> _freeBatchItemQueue;

	                /*readonly*/ GC_PTR<GraphicsDevice> _device;

                    GC_PTR<Riccsson::System::Array<short>> _index;

		            GC_PTR<Riccsson::System::Array<VertexPositionColorTexture>> _vertexArray;

		            public: SpriteBatcher (GC_PTR<GraphicsDevice> device)
								: _batchItemList( new Riccsson::System::Collections::Generic::List<GC_PTR<SpriteBatchItem>>(InitialBatchSize) )
                                , _freeBatchItemQueue( new Riccsson::System::Collections::Generic::Queue<GC_PTR<SpriteBatchItem>>(InitialBatchSize) )
                                , _index( new Riccsson::System::Array<short>(6 * InitialVertexArraySize) )
                                , _vertexArray( new Riccsson::System::Array<VertexPositionColorTexture>(4*InitialVertexArraySize) )
								, InitialBatchSize(256)
								, InitialVertexArraySize(256)
		            {
						throw;
		            }
		
		            public: GC_PTR<SpriteBatchItem> CreateBatchItem()
		            {
						throw;
		            }

				    private: static int CompareTexture ( SpriteBatchItem* a, SpriteBatchItem* b )
		            {
						return a->Texture.get()->GlTexture > b->Texture.get()->GlTexture;
		            }
                    
	                private: static int CompareDepth ( SpriteBatchItem* a, SpriteBatchItem* b )
		            {
			            return a->Depth > b->Depth;
		            }
                    
	                private: static int CompareReverseDepth ( SpriteBatchItem* a, SpriteBatchItem* b )
		            {
			            return b->Depth > a->Depth;
		            }
		
		            public: void DrawBatch(SpriteSortMode sortMode)
		            {
						throw;
		            }
				
		            void ExpandVertexArray( int batchSize )
		            {
						throw;
		            }

		            void FlushVertexArray( int start, int end )
		            {
						throw;
		            }
	            };
            }
		}
	}
}

#endif

